package chess;

/**
 *
 * @author Dave Frost
 */
public class Queen extends Piece
{
    
    public Queen(int color)
    {
        pieceColor = color;
    }//end of constructor
    
    public int canMove(int sourceX, int sourceY, int destX, int destY)
    {
        // Return false if coordinates are outside of the board.
        if(sourceX < 0 || sourceX > 7 || sourceY < 0 || sourceY > 7 ||
                destX < 0 || destX > 7 || destY < 0 || destY > 7)
            return 0;
        // Moving Rook Style
        if(sourceX == destX && sourceY != destY) 
        // Piece is moving vertically but not horizontally
        {
            return 1;
        }
        if(sourceX != destX && sourceY == destY)
        // Piece is moving horizontally but not vertically
        {
             return 1;
        } 
        /* So if it isn't moving like a rook going to Check Bishop Style
        *   Move Validation is the same for Bishop
        *   intializing variables
        */
        int distanceX;
        int distanceY;
        int magnitude;
        
        //Calculating distance
        distanceX= destX- sourceX;
        distanceY= destY- sourceY;
        
        if (distanceY==0)// to make sure you can't divid by Zero
            return 0;//invalid
        
        else
            magnitude= Math.abs(distanceX) / Math.abs(distanceY);
        
        if (magnitude ==1)
            return 1;//Valid
   
        return 0; // if it doesn't pass any validating test it is InValid
   
    } //end of canMove
    
    public char getType()
    {
        return 'Q';
    }//end of getType
    
    public static int getValue()
    {
        return 9;
    }//end of getValue
    
    
}//end of Queen
